const path = require('path')//引入内置path方便得到绝对路径
const HtmlWebpackPlugin = require("html-webpack-plugin"); // 引入html插件

module.exports = {
  mode:"development",
  entry: "./src/main.ts",//打包入口文件
  output: {
        path: path.resolve(__dirname, "./dist"),//出口文件，即打包后的文件存放地址
        filename: 'bundle.js' //文件名
  },
  resolve: {
    extensions: [".tsx", ".ts", ".js"]
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: "ts-loader",
        exclude: /node_modules/
      }
    ]
  },
  devtool: process.env.NODE_ENV === "production" ? "inline-source-map" : "inline-source-map",
  devServer: {
    static: "./dist",
    // stats: "errors-only",//出错了才会在页面显示
    compress: false,
    host: "localhost",
    port: 8080
  },
  plugins: [
    new HtmlWebpackPlugin({
        // 进入文件并打包
      template: "./public/index.html",
    })
  ]
};